/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UserFrame.java
 *
 * Created on Mar 24, 2011, 3:14:50 PM
 */

package gbbmgmt;

import java.util.*;
import org.jdesktop.application.Action;
import javax.swing.JOptionPane;

/**
 *
 * @author dchapman
 */
public class UserFrame extends javax.swing.JFrame {

    public ArrayList<String[]> Users;

    /** Creates new form UserFrame */
    public UserFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jComboBoxUsers = new javax.swing.JComboBox();
        jButtonCustFirst = new javax.swing.JButton();
        jButtonCustPrev = new javax.swing.JButton();
        jButtonCustNext = new javax.swing.JButton();
        jButtonCustLast = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldEmpID = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldEmpLastName = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldEmpFirstName = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jTextFielduserName = new javax.swing.JTextField();
        jTextFielduserPass = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jRadioButtonL0 = new javax.swing.JRadioButton();
        jRadioButtonL1 = new javax.swing.JRadioButton();
        jRadioButtonL2 = new javax.swing.JRadioButton();
        jRadioButtonL3 = new javax.swing.JRadioButton();
        jRadioButtonL4 = new javax.swing.JRadioButton();
        jSeparator3 = new javax.swing.JSeparator();
        jButtonUpdate = new javax.swing.JButton();
        jButtonDelete = new javax.swing.JButton();
        jButtonSubmit = new javax.swing.JButton();
        jButtonAdd = new javax.swing.JButton();
        jButtonExit = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jCheckBoxPOApprove = new javax.swing.JCheckBox();
        jCheckBoxSysAdmin = new javax.swing.JCheckBox();
        jCheckBoxPOApprove2 = new javax.swing.JCheckBox();
        jCheckBoxPOApprove3 = new javax.swing.JCheckBox();
        jCheckBoxPOApprove4 = new javax.swing.JCheckBox();
        jCheckBoxPOApprove5 = new javax.swing.JCheckBox();
        jSeparator4 = new javax.swing.JSeparator();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        jComboBoxUsers.setName("jComboBoxUsers"); // NOI18N
        jComboBoxUsers.addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
            public void popupMenuCanceled(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {
                jComboBoxUsersPopupMenuWillBecomeInvisible(evt);
            }
            public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {
            }
        });

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(gbbmgmt.GBBMGMTApp.class).getContext().getActionMap(UserFrame.class, this);
        jButtonCustFirst.setAction(actionMap.get("FirstRecord")); // NOI18N
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(gbbmgmt.GBBMGMTApp.class).getContext().getResourceMap(UserFrame.class);
        jButtonCustFirst.setText(resourceMap.getString("jButtonCustFirst.text")); // NOI18N
        jButtonCustFirst.setName("jButtonCustFirst"); // NOI18N

        jButtonCustPrev.setAction(actionMap.get("PrevRecord")); // NOI18N
        jButtonCustPrev.setText(resourceMap.getString("jButtonCustPrev.text")); // NOI18N
        jButtonCustPrev.setName("jButtonCustPrev"); // NOI18N

        jButtonCustNext.setAction(actionMap.get("NextRecord")); // NOI18N
        jButtonCustNext.setText(resourceMap.getString("jButtonCustNext.text")); // NOI18N
        jButtonCustNext.setName("jButtonCustNext"); // NOI18N

        jButtonCustLast.setAction(actionMap.get("LastRecord")); // NOI18N
        jButtonCustLast.setText(resourceMap.getString("jButtonCustLast.text")); // NOI18N
        jButtonCustLast.setName("jButtonCustLast"); // NOI18N

        jSeparator1.setName("jSeparator1"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jTextFieldEmpID.setEditable(false);
        jTextFieldEmpID.setText(resourceMap.getString("jTextFieldEmpID.text")); // NOI18N
        jTextFieldEmpID.setName("jTextFieldEmpID"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jTextFieldEmpLastName.setText(resourceMap.getString("jTextFieldEmpLastName.text")); // NOI18N
        jTextFieldEmpLastName.setName("jTextFieldEmpLastName"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jTextFieldEmpFirstName.setText(resourceMap.getString("jTextFieldEmpFirstName.text")); // NOI18N
        jTextFieldEmpFirstName.setName("jTextFieldEmpFirstName"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jTextFielduserName.setText(resourceMap.getString("jTextFielduserName.text")); // NOI18N
        jTextFielduserName.setName("jTextFielduserName"); // NOI18N

        jTextFielduserPass.setName("jTextFielduserPass"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jSeparator2.setName("jSeparator2"); // NOI18N

        buttonGroup1.add(jRadioButtonL0);
        jRadioButtonL0.setText(resourceMap.getString("jRadioButtonL0.text")); // NOI18N
        jRadioButtonL0.setName("jRadioButtonL0"); // NOI18N

        buttonGroup1.add(jRadioButtonL1);
        jRadioButtonL1.setText(resourceMap.getString("jRadioButtonL1.text")); // NOI18N
        jRadioButtonL1.setName("jRadioButtonL1"); // NOI18N

        buttonGroup1.add(jRadioButtonL2);
        jRadioButtonL2.setText(resourceMap.getString("jRadioButtonL2.text")); // NOI18N
        jRadioButtonL2.setName("jRadioButtonL2"); // NOI18N

        buttonGroup1.add(jRadioButtonL3);
        jRadioButtonL3.setText(resourceMap.getString("jRadioButtonL3.text")); // NOI18N
        jRadioButtonL3.setName("jRadioButtonL3"); // NOI18N

        buttonGroup1.add(jRadioButtonL4);
        jRadioButtonL4.setText(resourceMap.getString("jRadioButtonL4.text")); // NOI18N
        jRadioButtonL4.setName("jRadioButtonL4"); // NOI18N

        jSeparator3.setName("jSeparator3"); // NOI18N

        jButtonUpdate.setAction(actionMap.get("UpdateRecord")); // NOI18N
        jButtonUpdate.setText(resourceMap.getString("jButtonUpdate.text")); // NOI18N
        jButtonUpdate.setName("jButtonUpdate"); // NOI18N

        jButtonDelete.setAction(actionMap.get("DeleteRecord")); // NOI18N
        jButtonDelete.setText(resourceMap.getString("jButtonDelete.text")); // NOI18N
        jButtonDelete.setName("jButtonDelete"); // NOI18N

        jButtonSubmit.setAction(actionMap.get("SubmitRecord")); // NOI18N
        jButtonSubmit.setText(resourceMap.getString("jButtonSubmit.text")); // NOI18N
        jButtonSubmit.setName("jButtonSubmit"); // NOI18N

        jButtonAdd.setAction(actionMap.get("AddRecord")); // NOI18N
        jButtonAdd.setText(resourceMap.getString("jButtonAdd.text")); // NOI18N
        jButtonAdd.setName("jButtonAdd"); // NOI18N

        jButtonExit.setAction(actionMap.get("UserExit")); // NOI18N
        jButtonExit.setText(resourceMap.getString("jButtonExit.text")); // NOI18N
        jButtonExit.setName("jButtonExit"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jCheckBoxPOApprove.setText(resourceMap.getString("jCheckBoxPOApprove.text")); // NOI18N
        jCheckBoxPOApprove.setName("jCheckBoxPOApprove"); // NOI18N

        jCheckBoxSysAdmin.setText(resourceMap.getString("jCheckBoxSysAdmin.text")); // NOI18N
        jCheckBoxSysAdmin.setName("jCheckBoxSysAdmin"); // NOI18N

        jCheckBoxPOApprove2.setText(resourceMap.getString("jCheckBoxPOApprove2.text")); // NOI18N
        jCheckBoxPOApprove2.setName("jCheckBoxPOApprove2"); // NOI18N

        jCheckBoxPOApprove3.setText(resourceMap.getString("jCheckBoxPOApprove3.text")); // NOI18N
        jCheckBoxPOApprove3.setName("jCheckBoxPOApprove3"); // NOI18N

        jCheckBoxPOApprove4.setText(resourceMap.getString("jCheckBoxPOApprove4.text")); // NOI18N
        jCheckBoxPOApprove4.setName("jCheckBoxPOApprove4"); // NOI18N

        jCheckBoxPOApprove5.setText(resourceMap.getString("jCheckBoxPOApprove5.text")); // NOI18N
        jCheckBoxPOApprove5.setName("jCheckBoxPOApprove5"); // NOI18N

        jSeparator4.setName("jSeparator4"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jComboBoxUsers, 0, 317, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonCustFirst)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonCustPrev)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonCustNext)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonCustLast)
                .addContainerGap())
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTextFieldEmpID, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 304, Short.MAX_VALUE)
                        .addComponent(jButtonSubmit))
                    .addComponent(jTextFieldEmpFirstName)
                    .addComponent(jTextFieldEmpLastName, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTextFielduserName, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFielduserPass, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jRadioButtonL0)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jRadioButtonL1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jRadioButtonL2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jRadioButtonL3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jRadioButtonL4))
                    .addComponent(jLabel6))
                .addContainerGap(142, Short.MAX_VALUE))
            .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCheckBoxPOApprove)
                            .addComponent(jCheckBoxSysAdmin))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCheckBoxPOApprove3)
                            .addComponent(jCheckBoxPOApprove2))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCheckBoxPOApprove4)
                            .addComponent(jCheckBoxPOApprove5))))
                .addContainerGap(166, Short.MAX_VALUE))
            .addComponent(jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButtonUpdate)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonDelete)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonAdd)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 189, Short.MAX_VALUE)
                .addComponent(jButtonExit)
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jTextFielduserName, jTextFielduserPass});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                        .addComponent(jButtonCustPrev)
                        .addComponent(jButtonCustFirst)
                        .addComponent(jButtonCustNext)
                        .addComponent(jButtonCustLast))
                    .addComponent(jComboBoxUsers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextFieldEmpID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonSubmit))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextFieldEmpLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldEmpFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFielduserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFielduserPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButtonL0)
                    .addComponent(jRadioButtonL1)
                    .addComponent(jRadioButtonL2)
                    .addComponent(jRadioButtonL3)
                    .addComponent(jRadioButtonL4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCheckBoxPOApprove)
                    .addComponent(jCheckBoxPOApprove2)
                    .addComponent(jCheckBoxPOApprove4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCheckBoxSysAdmin)
                    .addComponent(jCheckBoxPOApprove3)
                    .addComponent(jCheckBoxPOApprove5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonUpdate)
                    .addComponent(jButtonDelete)
                    .addComponent(jButtonAdd)
                    .addComponent(jButtonExit))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBoxUsersPopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_jComboBoxUsersPopupMenuWillBecomeInvisible
        // TODO add your handling code here:
        String Itm = jComboBoxUsers.getSelectedItem().toString();

        for(String s[] : Users){
            String str = s[1] + ", " + s[2];
            if (str.equals(Itm)) {
                DBA.openDBCon();
                DBA.GetEmployeeData(s[0]);
                DBA.closeDBCon();
            }
        }
        SetData();
}//GEN-LAST:event_jComboBoxUsersPopupMenuWillBecomeInvisible

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new UserFrame().setVisible(true);
            }
        });
    }

    public void LoadList(){
        DBA.openDBCon();
        Users = DBA.RunSQLQuery("SELECT EmpID,EmpLastName,EmpFirstName FROM Employee");
        DBA.closeDBCon();

        for(String s[] : Users){
            String itm = s[1] + ", " + s[2];
            jComboBoxUsers.addItem(itm);
        }

        FirstRecord();
    }

    public void SetData(){
        jTextFieldEmpID.setText(Integer.toString(DBA.EmpID));
        jTextFieldEmpLastName.setText(DBA.EmpLastName);
        jTextFieldEmpFirstName.setText(DBA.EmpFirstName);
        jTextFielduserName.setText(DBA.userName);
        jTextFielduserPass.setText(DBA.userPass);
        if(DBA.userLevel == 0){
            jRadioButtonL0.setSelected(true);
        } else if(DBA.userLevel == 1){
            jRadioButtonL1.setSelected(true);
        } else if(DBA.userLevel == 2){
            jRadioButtonL2.setSelected(true);
        } else if(DBA.userLevel == 3){
            jRadioButtonL3.setSelected(true);
        } else {
            jRadioButtonL4.setSelected(true);
        }

        //Set the permissiosn accordingly.
        jCheckBoxPOApprove.setSelected(DBA.EmpPOApproval);
        jCheckBoxSysAdmin.setSelected(DBA.EmpSysAdmin);

        jButtonSubmit.setVisible(false);
    }

    @Action
    public void LastRecord() {
        jComboBoxUsers.setSelectedIndex(jComboBoxUsers.getItemCount()-1);

        String Itm = jComboBoxUsers.getSelectedItem().toString();

        for(String s[] : Users){
            String str = s[1] + ", " + s[2];
            if (str.equals(Itm)) {
                DBA.openDBCon();
                DBA.GetEmployeeData(s[0]);
                DBA.closeDBCon();
            }
        }
        SetData();
    }

    @Action
    public void FirstRecord() {
        jComboBoxUsers.setSelectedIndex(0);

        String Itm = jComboBoxUsers.getSelectedItem().toString();

        for(String s[] : Users){
            String str = s[1] + ", " + s[2];
            if (str.equals(Itm)) {
                DBA.openDBCon();
                DBA.GetEmployeeData(s[0]);
                DBA.closeDBCon();
            }
        }
        SetData();
    }

    @Action
    public void NextRecord() {
        if(jComboBoxUsers.getSelectedIndex() <= (jComboBoxUsers.getItemCount()-2)){
            jComboBoxUsers.setSelectedIndex(jComboBoxUsers.getSelectedIndex()+1);
        }

        String Itm = jComboBoxUsers.getSelectedItem().toString();

        for(String s[] : Users){
            String str = s[1] + ", " + s[2];
            if (str.equals(Itm)) {
                DBA.openDBCon();
                DBA.GetEmployeeData(s[0]);
                DBA.closeDBCon();
            }
        }
        SetData();
    }

    @Action
    public void PrevRecord() {
        if(jComboBoxUsers.getSelectedIndex()>=1){
            jComboBoxUsers.setSelectedIndex(jComboBoxUsers.getSelectedIndex()-1);
        }

        String Itm = jComboBoxUsers.getSelectedItem().toString();
        
        for(String s[] : Users){
            String str = s[1] + ", " + s[2];
            if (str.equals(Itm)) {
                DBA.openDBCon();
                DBA.GetEmployeeData(s[0]);
                DBA.closeDBCon();
            }
        }
        SetData();
    }

    @Action
    public void UpdateRecord() {
        int response = JOptionPane.showConfirmDialog(null,
                "This will modify employee data, continue?",
                "Warning",JOptionPane.WARNING_MESSAGE);

        if (response == 0){
            //User wants to update database, check for differences.
            DBA.openDBCon();

            String EmpID = jTextFieldEmpID.getText();

            String query = "UPDATE Employee SET EmpLastName='" +
                    jTextFieldEmpLastName.getText() + "',EmpFirstName='" +
                    jTextFieldEmpFirstName.getText() + "',userName='" +
                    jTextFielduserName.getText() + "', userPass='" +
                    jTextFielduserPass.getText() + "', EmpPOApproval='" +
                    Integer.toString((jCheckBoxPOApprove.isSelected())?1:0) + "', EmpSysAdmin='" +
                    Integer.toString((jCheckBoxSysAdmin.isSelected())?1:0) + "', userLevel='";

            if(jRadioButtonL0.isSelected()){
                query += "0' ";
            } else if(jRadioButtonL1.isSelected()){
                query += "1' ";
            } else if(jRadioButtonL2.isSelected()){
                query += "2' ";
            } else if(jRadioButtonL3.isSelected()){
                query += "3' ";
            } else if(jRadioButtonL4.isSelected()){
                query += "4' ";
            }

            query += "WHERE EmpID='" + EmpID + "'";

            DBA.RunSQLUpdateQuery(query);

            DBA.closeDBCon();

            SetData();
        }
    }

    @Action
    public void UserExit() {
        dispose();
    }

    @Action
    public void AddRecord() {
        //Make all appropriate variables blank.
        jComboBoxUsers.setVisible(false);
        jButtonCustFirst.setVisible(false);
        jButtonCustLast.setVisible(false);
        jButtonCustNext.setVisible(false);
        jButtonCustPrev.setVisible(false);
        jLabel1.setVisible(false);
        jTextFieldEmpID.setVisible(false);
        jButtonUpdate.setVisible(false);
        jButtonAdd.setVisible(false);
        jButtonDelete.setVisible(false);

        jButtonSubmit.setVisible(true);

        //reset text on all fields.
        jTextFieldEmpLastName.setText("");
        jTextFieldEmpFirstName.setText("");
        jTextFielduserName.setText("");
        jTextFielduserPass.setText("");
        jRadioButtonL4.setSelected(true);
    }

    @Action
    public void SubmitRecord() {
        int response = JOptionPane.showConfirmDialog(null,
                "This will add new employee data, continue?",
                "Warning",JOptionPane.WARNING_MESSAGE);

        if (response == 0){

            String uLevel = "5";
            if(jRadioButtonL0.isSelected()){
                uLevel = "0";
            } else if(jRadioButtonL1.isSelected()){
                uLevel = "1";
            } else if(jRadioButtonL2.isSelected()){
                uLevel = "2";
            } else if(jRadioButtonL3.isSelected()){
                uLevel = "3";
            } else if(jRadioButtonL4.isSelected()){
                uLevel = "4";
            }

            String query = "'" +
                jTextFieldEmpLastName.getText() + "','" +
                jTextFieldEmpFirstName.getText() + "','" +
                jTextFielduserName.getText() + "','" +
                jTextFielduserPass.getText() + "','" +
                uLevel + "','" +
                Integer.toString((jCheckBoxPOApprove.isSelected())?1:0) + "','" +
                Integer.toString((jCheckBoxSysAdmin.isSelected())?1:0) + "'";

            String fields = "EmpLastName,EmpFirstName,userName,userPass,userLevel,EmpPOApproval,EmpSysAdmin";

            if(jTextFieldEmpLastName.getText().equals("") ||
                    jTextFieldEmpFirstName.getText().equals("") ||
                    jTextFielduserName.getText().equals("") ||
                    jTextFielduserPass.getText().equals("")){
                //Required fields are not set.
                JOptionPane.showMessageDialog(null,
                        "Please enter all data!",
                        "Error",JOptionPane.ERROR_MESSAGE);
            } else {
                //Enter information into database.
                DBA.openDBCon();
                DBA.RunSQLInsertQuery("Employee",fields,query);
                DBA.closeDBCon();
            }
            jComboBoxUsers.setVisible(true);
            jButtonCustFirst.setVisible(true);
            jButtonCustLast.setVisible(true);
            jButtonCustNext.setVisible(true);
            jButtonCustPrev.setVisible(true);
            jLabel1.setVisible(true);
            jTextFieldEmpID.setVisible(true);
            jButtonUpdate.setVisible(true);
            jButtonAdd.setVisible(true);
            jButtonDelete.setVisible(true);
            jButtonSubmit.setVisible(false);

            jComboBoxUsers.removeAllItems();
            LoadList();
            LastRecord();
        }
    }

    @Action
    public void DeleteRecord() {
        String query = "DELETE FROM Employee WHERE EmpID = '"
                + jTextFieldEmpID.getText() + "'";
        int response = JOptionPane.showConfirmDialog(null,
                "Do you want to delete this entry from the Database?",
                "Warning",JOptionPane.WARNING_MESSAGE);
        if (response == 0){
            DBA.openDBCon();
            DBA.RunSQLUpdateQuery(query);
            DBA.closeDBCon();
            jComboBoxUsers.removeAllItems();
            LoadList();
            LastRecord();
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButtonAdd;
    private javax.swing.JButton jButtonCustFirst;
    private javax.swing.JButton jButtonCustLast;
    private javax.swing.JButton jButtonCustNext;
    private javax.swing.JButton jButtonCustPrev;
    private javax.swing.JButton jButtonDelete;
    private javax.swing.JButton jButtonExit;
    private javax.swing.JButton jButtonSubmit;
    private javax.swing.JButton jButtonUpdate;
    private javax.swing.JCheckBox jCheckBoxPOApprove;
    private javax.swing.JCheckBox jCheckBoxPOApprove2;
    private javax.swing.JCheckBox jCheckBoxPOApprove3;
    private javax.swing.JCheckBox jCheckBoxPOApprove4;
    private javax.swing.JCheckBox jCheckBoxPOApprove5;
    private javax.swing.JCheckBox jCheckBoxSysAdmin;
    private javax.swing.JComboBox jComboBoxUsers;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JRadioButton jRadioButtonL0;
    private javax.swing.JRadioButton jRadioButtonL1;
    private javax.swing.JRadioButton jRadioButtonL2;
    private javax.swing.JRadioButton jRadioButtonL3;
    private javax.swing.JRadioButton jRadioButtonL4;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JTextField jTextFieldEmpFirstName;
    private javax.swing.JTextField jTextFieldEmpID;
    private javax.swing.JTextField jTextFieldEmpLastName;
    private javax.swing.JTextField jTextFielduserName;
    private javax.swing.JTextField jTextFielduserPass;
    // End of variables declaration//GEN-END:variables

}
